import { BaseEntity } from "src/baseEntity";
import { DeptRoleEnum, RoleEnum } from "src/role/role.enum";
import { Column, Entity, JoinColumn, ManyToOne, OneToOne } from "typeorm";


export enum WorkflowType {
    user = "user",
    dept = "dept"
}

@Entity("v2_apply_workflow")
export class V2ApplyWorkflow extends BaseEntity {
    @Column()
    name: string

    @OneToOne(() => V2ApplyWorkflow, { orphanedRowAction: "delete", onDelete: "SET NULL" })
    @JoinColumn()
    next: V2ApplyWorkflow

    @OneToOne(() => V2ApplyWorkflow)
    target: V2ApplyWorkflow

    @Column({ type: "enum", enum: WorkflowType })
    type: WorkflowType

    @Column({ type: "enum", enum: RoleEnum, nullable: true })
    userRole: RoleEnum

    @Column({ type: "enum", enum: DeptRoleEnum, nullable: true })
    deptRole: DeptRoleEnum
}